Skip to content

Corrected wrong DFS implementation#903

Merged
poyea merged 1 commit into
TheAlgorithms:masterfrom
ziyzhu:master
Jun 17, 2019
Merged

Corrected wrong DFS implementation#903
poyea merged 1 commit into
TheAlgorithms:masterfrom
ziyzhu:master

Conversation

@ziyzhu

@ziyzhu ziyzhu commented Jun 15, 2019

Copy link
Copy Markdown
Contributor

explored set should not append the root/start outside of the while loop because the root/start is already in explored set and stack would be empty after the first pop. The "if v in explored" statement then triggers "continue" then it would exit the loop. As a result, this implementation would always return {'A'}.

@poyea poyea left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your pull request!🤩

@poyea poyea merged commit 55e0b0f into TheAlgorithms:master Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants